<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php?option=com_articlecashrewards" method="post" name="adminForm">
<script>
    function activateControls(invoker){
        level_value = document.getElementById('level_container');
        if(invoker.value == '<?php echo REFEREE_LEVEL_POST_ARTICLES ?>'){
            level_value.style.visibility = 'visible';
        }else{
            level_value.style.visibility = 'hidden';
        }
    }
</script>
<div id="submenu-box">
    <div class="t">
        <div class="t">
            <div class="t"></div>
        </div>
    </div>
    <div class="m">
        <ul id="submenu">
            <li>
                <a href="index.php?option=com_articlecashrewards&controller=referrals&task=pending"><?php echo JText::_('LABEL_PENDING');?></a>
            </li>
            <li>
                <a href="index.php?option=com_articlecashrewards&controller=referrals&task=reviewed"><?php echo JText::_('LABEL_REVIEWED');?></a>
            </li>
            <li>
                <a href="index.php?option=com_articlecashrewards&controller=referrals&task=recalcpage"><?php echo JText::_('LABEL_RUN_REFERRAL');?></a>
            </li>
            <li>
                <a class="active" href="index.php?option=com_articlecashrewards&controller=referrals&task=manageRules"><?php echo JText::_('LABEL_REFERRAL_RULES');?></a>
            </li>
        </ul>
        <div class="clr"></div>
    </div>
    <div class="b">
        <div class="b">
            <div class="b"></div>
        </div>
    </div>
</div>
<table class="adminlist" width="100%">
    <tr>
        <td width="100%">
            <fieldset class="adminform">
            <table class="admintable" cellspacing="1">
                <tr>
                    <td class="key">
                        <span class="editlinktip hasTip" title="<?php echo JText::_('REFERRAL_CRITERIA_DESC'); ?>">
                            <?php echo JText::_('REFERRAL_CRITERIA'); ?>
                        </span>
                    </td>
                    <td>
                        <select name="level_desc" id="level_desc" onclick="javascript: activateControls(this);">
                            <option value="<?php echo REFEREE_LEVEL_REGISTERED ?>"><?php echo REFEREE_LEVEL_REGISTERED ?>
                            <option value="<?php echo REFEREE_LEVEL_ACTIVATED ?>"><?php echo REFEREE_LEVEL_ACTIVATED ?>
                            <option value="<?php echo REFEREE_LEVEL_POST_ARTICLES ?>"><?php echo REFEREE_LEVEL_POST_ARTICLES ?>
                            <option value="<?php echo REFEREE_LEVEL_PAID ?>"><?php echo REFEREE_LEVEL_PAID ?>
                        </select>
                        &nbsp;&nbsp;
                        <span style="visibility: hidden;" id="level_container">
                            <?php echo JText::_('NO_OF_ARTICLES'); ?>&nbsp;<input type="text" name="level_value" id="level_value" value=""/>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <span class="editlinktip hasTip" title="">
                            <?php echo JText::_('PAYMENT_AMOUNT'); ?>
                        </span>
                    </td>
                    <td>
                        <input type="text" name="level_amount" id="level_amount" value="">
                    </td>
                </tr>
                <tr>
                    <td class="key">
                        <span class="editlinktip hasTip" title="">
                            <?php echo JText::_('LABEL_STATUS'); ?>
                        </span>
                    </td>
                    <td>
                        <?php echo JText::_('TOOLTIP_PUBLISHED'); ?><input type="radio" name="level_status" id="level_published" value="1" checked>
                        <?php echo JText::_('TOOLTIP_UNPUBLISHED'); ?><input type="radio" name="level_status" id="level_unpublished" value="0">
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" class="button" value="Save">
                    </td>
                </tr>
            </table>
            </fieldset>
        </td>
    </tr>
    <tr>
        <td>
            <table class="adminlist" cellspacing="1">
                <thead>
                    <tr>
                        <th width="5">
                            <?php echo JText::_( 'Num' ); ?>
                        </th>
                        <th width="10">
                            <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->rows ); ?>);" />
                        </th>
                        <th>
                            <?php echo JText::_('LABEL_LEVEL_ID'); ?>
                        </th>
                        <th>
                            <?php echo JText::_('REFERRAL_CRITERIA'); ?>
                        </th>
                        <th width="10%" class="title">
                            <?php echo JText::_('NO_OF_ARTICLES'); ?>
                        </th>
                        <th width="10%" class="title">
                            <?php echo JText::_('LABEL_AMOUNT'); ?>
                        </th>
                        <th width="10%" class="title">
                            <?php echo JText::_('LABEL_STATUS'); ?>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if($this->rows){
                        $k = 0;
                        $i = 0;
                        foreach ($this->rows as $row){
                            $checked 	= JHTML::_('grid.id', $i,  $row->id  );
                            ?>
                            <tr class="<?php echo "row$k"; ?>">
                                <td align="left">
                                    <?php echo $this->pagination->getRowOffset( $i); ?>
                                </td>
                                <td align="left">
                                    <?php echo $checked; ?>
                                </td>
                                <td align="left">
                                    <?php echo $row->id; ?>
                                </td>
                                <td align="left">
                                    <?php echo $row->description; ?>
                                </td>
                                <td align="left">
                                    <?php echo ($row->articles == '0')?'NA':$row->articles; ?>
                                </td>
                                <td align="left">
                                    <?php echo $row->amount; ?>
                                </td>
                                <td align="left">
                                    <?php
                                        if($row->published == 1){
                                            $img = 'published.png';
                                            $alt = 'TOOLTIP_PUBLISHED';
                                        }else{
                                            $img = 'rejected.png';
                                            $alt = 'TOOLTIP_UNPUBLISHED';
                                        }
                                    ?>
                                    <img src="components/com_articlecashrewards/assets/images/<?php echo $img; ?>"
                                        border="0" title="<?php echo JText::_( $alt ); ?>"
                                        alt="<?php echo JText::_( $alt ); ?>" />
                                </td>
                            </tr>
                            <?php
                            $k = 1 - $k;
                            $i++;
                        }
                    }
                    ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="8" nowrap="nowrap"><?php echo $this->pagination->getListFooter(); ?></td>
                    </tr>
                </tfoot>
            </table>
        </td>
    </tr>
</table>
<input type="hidden" name="option" value="com_articlecashrewards" />
<input type="hidden" name="controller" value="referrals" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="task" value="addLevel" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
